import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    host: "0.0.0.0",
    allowedHosts: ["www.hcsy.asia", "localhost", "121.43.236.207"],
    proxy: {
      // HTTP API 代理
      "/api": {
        target: "http://121.43.236.207:8080",
        changeOrigin: true,
        secure: false,
        rewrite: (p) => p.replace(/^\/api/, ""),
      },
      // WebSocket 代理
      "/ws": {
        target: "ws://121.43.236.207:8080",
        ws: true,
        changeOrigin: true,
        secure: false,
      },
    },
  },
});
